﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KPIS.GERP.Models.HRM;
using KPIS.GERP.Models.SYS;
using KPIS.GERP.Models.ViewModel;

namespace KPIS.GERP.Models.Class
{
    public static class ApproveUtility
    {
        public static ApprovalTaskDtl CopyAppDtlFromApprover(ApproverPassCondition approver, int fromEmpId, ApprovalTask approvalTask)
        {
            var approvalTaskDtl = new ApprovalTaskDtl();
             
            approvalTaskDtl.ApproverType = approver.ApproverType;
            approvalTaskDtl.ExecPosGroupId = approver.ExecPosId;
            approvalTaskDtl.PosId = approver.Employee.PosId;
            approvalTaskDtl.AmountMin = approver.AmountMin;
            approvalTaskDtl.AmountMax = approver.AmountMax;
            approvalTaskDtl.ApprovalTaskId = approvalTask.ApprovalTaskId;
            approvalTaskDtl.IsCancel = false;
            approvalTaskDtl.CreatedBy = fromEmpId;
            approvalTaskDtl.CreatedWhen = DateTime.Now;
            approvalTaskDtl.TaskStatusBefore = approvalTask.ApprovalTaskStatus;
            approvalTaskDtl.CreatedOnActionCount = approvalTask.ActionCount;

            approvalTaskDtl.IsApproveAble = approver.IsApproveAble;
            approvalTaskDtl.IsForwardable = approver.IsForwardable;
            approvalTaskDtl.IsRejectable = approver.IsRejectable;
            approvalTaskDtl.IsPendable = approver.IsPendable;
            approvalTaskDtl.IsSendBackable = approver.IsSendBackable;
            approvalTaskDtl.IsLockable = approver.IsLockable;
            approvalTaskDtl.IsTakebackAble = approver.IsTakebackAble;
            return approvalTaskDtl;
        }

        public static ApproverPassCondition CopyApproverFromApprovePath(ApprovePath approvePath, Employee emp, int empId)
        {
            var ac = new ApproverPassCondition
                {
                    AmountMax = approvePath.AmountMax,
                    AmountMin = approvePath.AmountMin,
                    ExecPosId = approvePath.ExecPosId,
                    ByPosId = approvePath.PosId,
                    ApproverType = approvePath.ApproverType,
                    Employee = emp,
                    EmpId = empId,
                    IsApproveAble = approvePath.IsApproveAble,
                    IsForwardable = approvePath.IsForwardable,
                    IsRejectable = approvePath.IsRejectable,
                    IsPendable = approvePath.IsPendable,
                    IsSendBackable = approvePath.IsSendBackable,
                    IsLockable = approvePath.IsLockable,
                };
            return ac;
        }

    }
}